package com.gw.vip.server.service.dao_service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gw.vip.common.exception.ServiceException;
import com.gw.vip.server.dao.UserInfoMapper;
import com.gw.vip.server.po.UserInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author GW
 * @description
 * @since 2022-04-26
 */
@Service
public class UserInfoService extends ServiceImpl<UserInfoMapper, UserInfo> {
    public UserInfo getByNickName(String nickName) {
        if (StringUtils.isBlank(nickName)){
            log.error("nickName不能为空！");
            throw new ServiceException("nickName不能为空！");
        }
        QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(UserInfo::getNickName, nickName);
        return getOne(queryWrapper);
    }
}
